<?php
/**
 * File: language_helper.php
 * Created on: Aug 10, 2010
 * Author: Dat Nguyen
 * 
 */

/**
 * The translate model supports parameters in two form:
 *  1. %key
 *  2. %{key}
 * 
 * Passed $params is an array formated as: array('key' => 'value')
 */
if ( !function_exists('__') )
{
	function __($text, $params = array())
	{
		$msg = T_gettext($text);
		if (isset($params) && count($params) && $msg)
		{
			$t_params = array();
			foreach ($params as $key => $value)
			{
				$t_params['%{' . $key . '}'] = $t_params['%' . $key] = $value;
			}
			unset($params);
			$msg = strtr($msg, $t_params);
		}
		return $msg;
	}
}

?>
